
#ifndef __gui_sceneH__
#define __gui_sceneH__

#include "gui_widgets.h"
#include "gui_window.h"

namespace WtfGui {
	/**
	 * Scene widget - displays a rendered scene
	 **/
	class Scene: public virtual WtfEngine::IDynamic, public Widget {
		WtfEngine::FBOTexture::tRef	mrScene;
		WtfEngine::IPerspective::tRef	mrCamera;
		bool						mbUpdate;

	public:
		Scene(const WtfEngine::IPerspective::tRef& rCamera, const iVector2D& vSize):
		  Widget("Scene"), mrCamera(rCamera), mbUpdate(false) {
			  Resize(vSize, iVector2D());
			  setUpdate(true);
		};

		WtfEngine::FBOTexture::tRef getFrameBuffer() const {
			return mrScene;
		};

		WtfEngine::IPerspective::tRef	getCamera() const {
			return mrCamera;
		};
		void						setCamera(const WtfEngine::IPerspective::tRef& rCamera) {
			mrCamera = rCamera;
		};
		
		virtual void Update();
		virtual void Paint(float d);

		inline bool getUpdate() const {
			return mbUpdate;
		};

		inline void setUpdate(bool bUpdate) {
			if(bUpdate != mbUpdate) {
				if(bUpdate) WtfEngine::IDynamic::Init();
				else		WtfEngine::IDynamic::Destroy();
				mbUpdate = bUpdate;
			};
		};

		virtual void OnResize();

		virtual void Destroy();

		GC_AUTOSIZE(Scene);
	};

	/**
	 * Displays diagnostic info about the simulation, e.g. frame rate
	 **/
	class SceneDiagnostics: public virtual WtfEngine::IDynamic, public Window {
		Widgets::Label::tRef	mrLblFPS;

	public:
		SceneDiagnostics();

		virtual void Update();
		virtual void OnResize();

		GC_AUTOSIZE(SceneDiagnostics);
	};
};

#endif
